﻿#region Header
/*
 * name：ResourceReader
 * author：Kain
 * date：12/2/2010 11:09:02 AM
 *********************************************
 * History:
 * $Header$
 * $History$
 */
#endregion

#region imported namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Resources;
using System.Collections;
#endregion

namespace Janus.Cores.Globalization
{
    internal class ResourceReader : IResourceReader
    {

        Dictionary<string,LanguageEntry> _items = null;
        public ResourceReader(Dictionary<string, LanguageEntry> items)
        {
            _items = items;
        }
        #region IResourceReader Members

        public void Close()
        {

        }

        public System.Collections.IDictionaryEnumerator GetEnumerator()
        {
            return new DictionaryEnumerator(_items.GetEnumerator());
        }

        
        
        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {

        }

        #endregion

        class DictionaryEnumerator : IDictionaryEnumerator
        {

            IEnumerator<KeyValuePair<string, LanguageEntry>> _dict;
            public DictionaryEnumerator(IEnumerator<KeyValuePair<string,LanguageEntry>> dict)
            {
                _dict = dict;
            }
            public DictionaryEntry Entry
            {
                get
                {
                    return new DictionaryEntry(_dict.Current.Key, _dict.Current.Value);
                }
            }

            public object Key
            {
                get { return _dict.Current.Key; }
            }

            public object Value
            {
                get { return _dict.Current.Value; }
            }

            public object Current
            {
                get { return Entry; }
            }

            public bool MoveNext()
            {
                return _dict.MoveNext();
            }

            public void Reset()
            {
                _dict.Reset();
            }
        }
    }
}
